home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Snippets / Networking / AFP C++ / TestAFP.cp < prev    next >
Encoding:
Text File  |  1992-05-01  |  1.2 KB  |  56 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3. Created: Tuesday, November 6, 1991
  4.     TestAFP.cp
  5.     Testing and sample code for the AFP C++ library code
  6.  
  7.         Copyright Apple Computer, Inc. 1985-1991
  8.         All rights reserved
  9.  
  10. ************************************************************/
  11. #include "TestSession.h"
  12. #include "stream.h"
  13.  
  14. const Byte kShortName = 1;
  15. const Byte kLongName = 2;
  16. const Byte kSoftCreate = 0x00;
  17. const Byte kHardCreate = 0x80;
  18. const long kRootDirID = 2;
  19. const Byte kRsrcFork = 0x80;
  20. const Byte kDataFork = 0x00;
  21.  
  22. int main() {
  23.  
  24.     TestSession * client;
  25.     short ForkID;
  26.     short VolID;
  27.     long DirID;
  28.  
  29.     client = new TestSession;
  30.  
  31.     client->SetPrint( true );
  32.  
  33.     client->ISession( "*", "Milkyway" );
  34.  
  35.     client->LoginCleartxt( "Utopia", "paradise" );
  36.  
  37.     client->OpenVol( "Orion", "", 0x20 );
  38.  
  39.     VolID = client->GetVolumeID();
  40.     
  41.     client->CreateDir( VolID, 2, kLongName, "NewDirectory" );
  42.     
  43.     DirID = client->GetDirID();
  44.     
  45.     client->CreateFile( VolID, DirID, kHardCreate, kLongName, "NewFile" );
  46.  
  47.     client->OpenFork( kDataFork, VolID, DirID, 0, 0x03, kLongName, "NewFile" );
  48.  
  49.     ForkID = client->GetForkID();
  50.     
  51.     client->Write( ForkID, 0,11, 0, "Hello World" );
  52.     
  53.     client->Logout();
  54.     delete client;
  55.     return 0;
  56. }